/*
 * Powered By [ERP]
 * Since 2014 - 2016
 */


package com.apis.restful.user.controller;

import com.apis.javacommon.response.JsonResult;
import com.apis.restful.user.model.User;
import com.apis.restful.user.query.UserQuery;
import com.apis.restful.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author smn email:shimengnan007@163.com
 * @version 1.0
 * @since 1.0
 */
@RestController
public class UserController{

	@Autowired
	private UserService userService;
	/** 获取所有数据*/
	@RequestMapping(value="/user/byname",method=RequestMethod.POST)
	@ResponseBody
	public JsonResult indexAll(@RequestBody UserQuery query) {
		JsonResult result=new JsonResult();
		result.setData(this.userService.getByName(query));
		result.success();
		return result;
	}

	/** 保存新增 */
	@RequestMapping(value="/user",method=RequestMethod.PUT)
	@ResponseBody
	public JsonResult create(@RequestBody User user) throws Exception {
		userService.save(user);
		
		JsonResult result=new JsonResult();
		result.success();
		return result;
	}

}

